package com.pubinfo.passbook.common.model.bo.witeoff;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.pubinfo.passbook.common.entity.*;
import com.pubinfo.passbook.common.model.bo.witeoff.subitem.MedicineOnJobOrRetireSubitem;
import com.pubinfo.passbook.common.model.ruler.PayInformation;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.collections4.CollectionUtils;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

@Data
@ApiModel(value = "WiteoffBase", description = "报账单基础数据")
public class WiteoffBase extends Object implements Serializable {
  
  public static final long serialVersionUID = 7424497997148290435L;
  @ApiModelProperty(value = "外围系统主单唯一标志，每次报账都必须是唯一，不允许重复.")
  public String otherSystemMainId;
  @ApiModelProperty(value = "报账人账号 集团统一用户目录账号（全国唯一）")
  public String account;
  @ApiModelProperty(value = "报账人姓名")
  public String fillInName;
  @ApiModelProperty(value = "报账组织编码 可以通过“获取报账组织信息”接口获取")
  public String fillInOrgCode;
  
  @ApiModelProperty(value = "公司代码  先做两种 (上市 ：A011、存续：B011) 用户自己选择")
  public String sapCompayCode;
  
  @ApiModelProperty(value = "经济事项编码   (在职及供属医药费) 10040808, (退休员工医药费) 10040813, " +
      "(环保费) 10040701 , (社会团体会费) 10040404" +
      "污水处理费的报账分三种：  \n " +
      "1、财政票据走“10040404行政事业社团收费”；  \n " +
      "2、收款人非政府和自来水公司的发票走“10040701绿化环保”（暂不做自动报账）；  \n " +
      "3、政府和自来水公司的发票走能耗集成“水费”（能耗系统暂不接入）。  \n ")
  public String economicItemCode;
  
  @ApiModelProperty(value = "经济事项名称  (在职及供属医药费)- 医药, (退休员工医药费) -离退休人员相关费用, (环保费) -环保费的发票分三种情况，涉及三个经济事项，绿化环保、行政事业社团收费、水费." +
      "刚上线先只做走行政事业社团收费的环保费发票 , (社会团体会费)- 行政事业社团收费")
  public String economicItemName;
  
  @ApiModelProperty(value = "收支方式 选项：" +
      "1 已支付-委托银行划扣-本地划扣 " +
      "2 已支付-本地已主动支付 " +
      "3 已支付-委托银行划扣-集中划扣 " +
      "4 (默认)涉及付款-银行支付-集中支付   " +
      "8 不涉及收付")
  public String paymentType = "4";
  @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
  @ApiModelProperty("报账人手机号")
  private String phone;
  @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
  @ApiModelProperty("是否需要审核")
  private Boolean isNeedAudit = false;
  @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
  @ApiModelProperty("是否是退后再审核")
  private Boolean isAgain = false;
  @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
  @ApiModelProperty("退回单据id")
  private String againWiteoffId = null;
  @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
  @ApiModelProperty("退回单据外围主键id")
  private String againOtherSystemMainId = null;
  /**
   * 批id 只有在自动报账时才使用
   */
  @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
  @ApiModelProperty(hidden = true)
  private TAutoWiteoffManage manage = new TAutoWiteoffManage();
  
  @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
  @ApiModelProperty(hidden = true)
  public String detalis;
  public String singleClearFlag = "1";
  @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
  @ApiModelProperty("报账人身份证号")
  private String idNo;
  @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
  @ApiModelProperty("报账人所属公司代码")
  private String nsrsbh;
  @ApiModelProperty(value = "费用发生日 必须 格式为：YYYY-MM-DD")
  @JsonFormat(pattern = "yyyy-MM-dd")
  public String happenDate;
  
  @ApiModelProperty(value = "手工录入单据列表")
  public List<TSourceArtificial> artificials = new ArrayList<>();
  @ApiModelProperty(value = "报账期间   格式必为：YYYY-MM")
  public String budgetSet;
  @ApiModelProperty(value = "业务类型 选项：0-列账，1-付款,2-列并付(默认)")
  public String bizType = "2";
  @ApiModelProperty(value = "会计科目编码 非必须 可从SAP获取基础数据 当收支方式是4时，会计科目编码默认为：1002B88P00，科目名称：省公司财务公司综合户01001 ；  \n " +
      "当收支方式为1、2、3时，根据利润中心提供银行科目列表，如右图。")
  public String accountCode;
  
  @ApiModelProperty(value = "会计科目名称 非必须 　当收支方式是4时， 科目名称：省公司财务公司综合户01001 当收支方式为1、2、3时，根据利润中心提供银行科目列表")
  public String accountName;
  @ApiModelProperty(value = "科目类型 非必须 选输(1-总账(默认)、2-供应商、3-客户),有科目时必须")
  public String accountType = "1";
  @ApiModelProperty(value = "是否员工代垫 必须 如不涉及银行支付，请提供空值," +
      " 选项：0-否，1-是  <br/> " +
      " 为 (在职及供属医药费) 时 为 1 是  <br/> " +
      " 为   (退休员工医药费) (环保费)  (社会团体会费) 是为 0 否")
  public Byte isStaffPayment;
  
  @ApiModelProperty(value = "业务编码类型 非必须 选项 1-合同  3-采购订单号  5-框架汇总单号 如果为空，而且合同编码/业务编码字段又存在，则默认为1-合同")
  public Byte bizCodeType = 1;
  @ApiModelProperty(value = "合同编码/业务编码")
  public String contractNo;
  @ApiModelProperty(value = "合同名称/业务名称")
  public String contractName;
  @ApiModelProperty(value = "报账金额 必须 子单总金额必需等于报账金额")
  public BigDecimal sum = BigDecimal.ZERO;
  @ApiModelProperty(value = "说明 (在职及供属医药费) 时默认：" +
      " 报XXX（收款人）医药费" +
      "     (退休员工医药费) 默认：报XXX医药费" +
      " (环保费)时 发票内容含“污水处理”：默认“报XXX污水处理费”" +
      "(团体会费)时 发票内容含“团体会费”：默认“报XXX团体会费”   ")
  public String desc;
  
  @ApiModelProperty(value = "票据类型 非必须 当集成业务涉及增值税时，必须。 选项：" +
      "1-增值税专用发票，2-增值税普通发票，3-营业税发票，4-货物运输专用发票，" +
      "5-机动车销售统一发票，6-海关进口增值税专用缴款书，8-普通收据，9无发票，" +
      "10-国外发票（国外账单），11-代扣代缴税收通用缴款书，12-电子发票-普票，" +
      "13-增值税专用发票（免税高新企业），14-通行费电子发票，15-通用发票" +
      "目前这些选项中省系统只要提供“12-电子发票-普票”这一种票据类型，19-财政电子票据。")
  public Byte invoiceType;
  @ApiModelProperty(value = "是否需要手工扫描 必须 0-否(默认)，1-是")
  // @JsonFormat(shape = JsonFormat.Shape.NUMBER)
  public Integer isNeedImage = 1;
  @ApiModelProperty(value = "是否调用预算  非必须  " +
      "0:不调用 1：调用(默认) 空：" +
      "通过经济事项+省级编码+外围系统标识到配置表进行查找")
  public Byte isBudget = 0;
  //@ApiModelProperty(value = "是否存在实物赠送  营改增业务必填 " +
  //    " 是否存在实物赠送 1：是0:否(默认) 实物  " +
  //    "赠送金额  DOUBLE  精确到2位小数点  实物赠送金额  营改增业务必填")
  //public Byte isRealGift = 0;
  @ApiModelProperty(value = "业务发生时间点标志  营改增业务必填  业务发生时间                                                点标志(1-[营改增日期]前，2-[营改增日期]后(默认))")
  public Byte businessHappenTimeFlag = 2;
  @ApiModelProperty(value = "纳税属性  非必须  " +
      "1-属地纳税、2-汇总纳税(默认)、3-汇总传统，" +
      "根据经济事项配置的数据默认推导")
  public Byte payTaxAttribute = 2;
  @ApiModelProperty(value = "业务场景（挑对模式）  非必须  业务场景（挑对模式）  \n " +
      "   * 1:冲前期借款（冲预付款） 2:挂账后付款（清偿应付款）   " +
      "3:冲预列（冲暂估） 7:挂账不付款（含预列） 8:预付款   9:挂账并付款(默认) ")
  public Byte pickingMode = 9;
  @ApiModelProperty(value = "是否加急 0-否(默认)，1-是")
  public String isEmergency = "0";
  @JsonIgnore
  public String getPhone() {
    return phone;
  }
  @JsonIgnore
  public Boolean getNeedAudit() {
    return isNeedAudit;
  }
  @JsonIgnore
  public Boolean getAgain() {
    return isAgain;
  }
  @JsonIgnore
  public String getIdNo() {
    return idNo;
  }
  @JsonIgnore
  public String getNsrsbh() {
    return nsrsbh;
  }
  @JsonIgnore
  public Boolean getProcessShort() {
    return isProcessShort;
  }
  @JsonIgnore
  public List<String> getInvoiceIds() {
    return invoiceIds;
  }
  @JsonIgnore
  public List<PayInformation> getPayInformations() {
    return payInformations;
  }
  @JsonIgnore
  public List<TRuleUserWiteoff> getWiteoffs() {
    return witeoffs;
  }

  @ApiModelProperty(value = "委托划扣银行账号")
  public String delegationBankCode;
  @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
  public Boolean isProcessShort = false; //是否为短流程
  @ApiModelProperty(value = "发票稽核  非必须  " +
      "当为1时，该集成单据稽核且稽核结果为“稽核通过”；" +
      " 当为0时，该集成单据稽核且稽核结果为“稽核不通过”")
  public Byte invoiceCheck;
  @ApiModelProperty(value = "关联供应商集合 当“业务类型”为1，2时，且“是否员工代垫”为0时，必须")
  public List<TWiteoffRelateSupplier> relateSuppliers = new ArrayList<>();
  @ApiModelProperty(value = "收款方信息集合 当“业务类型”为1，2时，要")
  public List<TWiteoffPayMent> payMentItems = new ArrayList<>();

  @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
  @ApiModelProperty(value = "关联发票id集合", required = true)
  public List<String> invoiceIds = new ArrayList<>();
  
  @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
  public List<PayInformation> payInformations = new ArrayList<>();
  @ApiModelProperty(hidden = true)
  public List<TWiteoffInvoiceInfo> invoiceInfos = new ArrayList<>();
  @ApiModelProperty(value = "报账审核资料集合")
  public List<TWiteoffAttchment> attchmentAdds = new ArrayList<>();
  @ApiModelProperty(value = "挑对记录 当业务场景是1、2、3时，要")
  public List<TWiteoffOpenPicking> openItemPickings = new ArrayList<>();
  @ApiModelProperty(value = "共享附件信息集合 当业务场景是1、2、3时，要")
  public List<TWiteoffShareAttachment> shareAttachmentItems = new ArrayList<>();
  @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
  public List<TRuleUserWiteoff> witeoffs = new ArrayList<>();
  
  /**
   * 报账子单信息集合
   */
  @ApiModelProperty(value = "报账子单信息集合", required = true)
  public List<MedicineOnJobOrRetireSubitem> lineItems = new ArrayList<>();
  
  @ApiModelProperty(hidden = true)
  public void setInvoices(List<TSourceNormal> normalList) {
    if (CollectionUtils.isEmpty(normalList)) {
      return;
    }
    normalList.stream().forEach(tSourceNormal -> {
    
    });
  }
  
  @JacksonXmlProperty(localName = "account")
  public String getAccount() {
    return account;
  }
  
  @JacksonXmlProperty(localName = "fillInName")
  public String getFillInName() {
    return fillInName;
  }
  
  @JacksonXmlProperty(localName = "fillInOrgCode")
  public String getFillInOrgCode() {
    return fillInOrgCode;
  }
  
  @JacksonXmlProperty(localName = "sapCompayCode")
  public String getSapCompayCode() {
    return sapCompayCode;
  }
  
  @JacksonXmlProperty(localName = "economicItemCode")
  public String getEconomicItemCode() {
    return economicItemCode;
  }
  
  @JacksonXmlProperty(localName = "economicItemName")
  public String getEconomicItemName() {
    return economicItemName;
  }
  
  @JacksonXmlProperty(localName = "paymentType")
  public String getPaymentType() {
    return paymentType;
  }
  
  @JacksonXmlProperty(localName = "happenDate")
  public String getHappenDate() {
    return happenDate;
  }
  
  @JacksonXmlProperty(localName = "budgetSet")
  public String getBudgetSet() {
    return budgetSet;
  }
  
  @JacksonXmlProperty(localName = "bizType")
  public String getBizType() {
    return bizType;
  }
  
  @JacksonXmlProperty(localName = "accountCode")
  public String getAccountCode() {
    return accountCode;
  }
  
  @JacksonXmlProperty(localName = "accountName")
  public String getAccountName() {
    return accountName;
  }
  
  @JacksonXmlProperty(localName = "accountType")
  public String getAccountType() {
    return accountType;
  }
  
  @JacksonXmlProperty(localName = "isStaffPayment")
  public Byte getIsStaffPayment() {
    return isStaffPayment;
  }
  
  @JacksonXmlProperty(localName = "bizCodeType")
  public Byte getBizCodeType() {
    return bizCodeType;
  }
  
  @JacksonXmlProperty(localName = "contractNo")
  public String getContractNo() {
    return contractNo;
  }
  
  @JacksonXmlProperty(localName = "contractName")
  public String getContractName() {
    return contractName;
  }
  
  @JacksonXmlProperty(localName = "sum")
  public BigDecimal getSum() {
    return sum;
  }
  
  @JacksonXmlProperty(localName = "desc")
  public String getDesc() {
    return desc;
  }
  
  @JacksonXmlProperty(localName = "invoiceType")
  public Byte getInvoiceType() {
    return invoiceType;
  }
  
  @JacksonXmlProperty(localName = "isNeedImage")
  public Integer getNeedImage() {
    return isNeedImage;
  }
  
  @JacksonXmlProperty(localName = "isBudget")
  public Byte getIsBudget() {
    return isBudget;
  }
  
  //@JacksonXmlProperty(localName = "isRealGift")
  //public Byte getIsRealGift() {
  //  return isRealGift;
  //}
  
  @JacksonXmlProperty(localName = "businessHappenTimeFlag")
  public Byte getBusinessHappenTimeFlag() {
    return businessHappenTimeFlag;
  }
  
  @JacksonXmlProperty(localName = "payTaxAttribute")
  public Byte getPayTaxAttribute() {
    return payTaxAttribute;
  }
  
  @JacksonXmlProperty(localName = "pickingMode")
  public Byte getPickingMode() {
    return pickingMode;
  }
  
  @JacksonXmlProperty(localName = "isEmergency")
  public String getIsEmergency() {
    return isEmergency;
  }
  
  @JacksonXmlProperty(localName = "delegationBankCode")
  public String getDelegationBankCode() {
    return delegationBankCode;
  }
  
  @JacksonXmlProperty(localName = "invoiceCheck")
  public Byte getInvoiceCheck() {
    return invoiceCheck;
  }
  
  @JacksonXmlElementWrapper(localName = "relateSuppliers")
  @JacksonXmlProperty(localName = "relateSupplier")
  public List<TWiteoffRelateSupplier> getRelateSuppliers() {
    return relateSuppliers;
  }
  
  @JacksonXmlElementWrapper(localName = "payMentItems")
  @JacksonXmlProperty(localName = "payMentItem")
  public List<TWiteoffPayMent> getPayMentItems() {
    return payMentItems;
  }
  
  @JacksonXmlElementWrapper(localName = "invoiceInfos")
  @JacksonXmlProperty(localName = "invoiceInfo")
  public List<TWiteoffInvoiceInfo> getInvoiceInfos() {
    return invoiceInfos;
  }
  
  @JacksonXmlElementWrapper(localName = "attchmentAdds")
  @JacksonXmlProperty(localName = "attchmentAdd")
  public List<TWiteoffAttchment> getAttchmentAdds() {
    return attchmentAdds;
  }
  
  @JacksonXmlElementWrapper(localName = "openItemPickings")
  @JacksonXmlProperty(localName = "openItemPicking")
  public List<TWiteoffOpenPicking> getOpenItemPickings() {
    return openItemPickings;
  }
  
  @JacksonXmlElementWrapper(localName = "shareAttachmentItems")
  @JacksonXmlProperty(localName = "shareAttachmentItem")
  public List<TWiteoffShareAttachment> getShareAttachmentItems() {
    return shareAttachmentItems;
  }
//
//  @JsonProperty("relateSuppliers")
//  public void setRelateSuppliers(List<TWiteoffRelateSupplier> relateSuppliers) {
//    this.relateSuppliers = relateSuppliers;
//  }
//
//  @JsonProperty("payMentItems")
//  public void setPayMentItems(List<TWiteoffPayMent> payMentItems) {
//    this.payMentItems = payMentItems;
//  }
//
//  @JsonProperty("invoiceInfos")
//  public void setInvoiceInfos(List<TWiteoffInvoiceInfo> invoiceInfos) {
//    this.invoiceInfos = invoiceInfos;
//  }
//
//  @JsonProperty("attchmentAdds")
//  public void setAttchmentAdds(List<TWiteoffAttchment> attchmentAdds) {
//    this.attchmentAdds = attchmentAdds;
//  }
//
//  @JsonProperty("openItemPickings")
//  public void setOpenItemPickings(List<TWiteoffOpenPicking> openItemPickings) {
//    this.openItemPickings = openItemPickings;
//  }
//
//  @JsonProperty("shareAttachmentItems")
//  public void setShareAttachmentItems(List<TWiteoffShareAttachment> shareAttachmentItems) {
//    this.shareAttachmentItems = shareAttachmentItems;
//  }
//
}
